let mongoose = require('mongoose');
let TaskConfig = mongoose.models['TaskConfig'];
let tasks = [
    /* 1 */
    {
        "reward" : [
            {
                "value" : 1,
                "gold" : 10,
                "diamond" : 0
            }
        ],
        "type" : 0,
        "id" : 0,
        "title" : "每日签到奖励",
        "desc" : "领取每日签到奖励"
    },

    /* 2 */
    {
        "reward" : [
            {
                "value" : 1,
                "gold" : 100,
                "diamond" : 100
            }
        ],
        "type" : 0,
        "id" : 1,
        "title" : "邀请好友",
        "desc" : "邀请{0}个好友激活"
    },

    /* 3 */
    {
        "reward" : [
            {
                "value" : 3,
                "gold" : 50,
                "diamond" : 20
            }
        ],
        "type" : 0,
        "id" : 2,
        "title" : "连赢奖励",
        "desc" : "当日连赢{0}局可领取",
        "value" : 1
    },

    /* 4 */
    {
        "reward" : [
            {
                "value" : 10,
                "gold" : 50,
                "diamond" : 20
            }
        ],
        "type" : 0,
        "id" : 3,
        "title" : "好友对抗奖励",
        "desc" : "参与好友对抗{0}局游戏，领取奖励",
        "value" : 1
    },

    /* 5 */
    {
        "reward" : [
            {
                "value" : 5,
                "gold" : 20,
                "diamond" : 10
            }
        ],
        "type" : 0,
        "id" : 4,
        "title" : "早自习奖励",
        "desc" : "每早上7:00-8:00玩满{0}局",
        "value" : 3
    },

    /* 6 */
    {
        "reward" : [
            {
                "value" : 5,
                "gold" : 20,
                "diamond" : 10
            }
        ],
        "type" : 0,
        "id" : 5,
        "title" : "晚自习奖励",
        "desc" : "每早上24:00-1:00玩满{0}局"
    },

    /* 7 */
    {
        "reward" : [
            {
                "value" : 5,
                "gold" : 50,
                "diamond" : 0
            },
            {
                "value" : 10,
                "gold" : 100,
                "diamond" : 0
            },
            {
                "value" : 15,
                "gold" : 150,
                "diamond" : 0
            },
            {
                "value" : 20,
                "gold" : 200,
                "diamond" : 0
            },
            {
                "value" : 25,
                "gold" : 150,
                "diamond" : 0
            },
            {
                "value" : 30,
                "gold" : 200,
                "diamond" : 0
            }
        ],
        "type" : 1,
        "id" : 0,
        "title" : "跳级奖励",
        "desc" : "等级提到升到{0}级，领取奖励"
    },

    /* 8 */
    {
        "reward" : [
            {
                "value" : 1,
                "gold" : 50,
                "diamond" : 0
            },
            {
                "value" : 2,
                "gold" : 100,
                "diamond" : 0
            },
            {
                "value" : 4,
                "gold" : 150,
                "diamond" : 0
            },
            {
                "value" : 8,
                "gold" : 200,
                "diamond" : 0
            },
            {
                "value" : 16,
                "gold" : 250,
                "diamond" : 0
            },
            {
                "value" : 32,
                "gold" : 300,
                "diamond" : 0
            }
        ],
        "type" : 1,
        "id" : 1,
        "title" : "累积邀请奖励",
        "desc" : "累积邀请激活{0}个新手进入游戏，领取奖励"
    }
]


async function register(){
    for(let i=0; i<tasks.length; i++){
        let task = tasks[i];
        let test = await TaskConfig.findOne({type:task.type,id:task.id})
        if(!test){
            await TaskConfig.create(task);
        } else {
            await test.updateOne(task)
        }
    }
}
register();

